package com.sufen.seckill.study.LeetCode;

/**
 * @Author sufen
 * @Date 2021/11/4 16:10
 * @Version 1.0
 * 功能描述：
 */
public class Offer_05_替换空格 {
    public static void main(String[] args) {
        System.out.println(replaceSpace("fuck u fucking guys"));
    }
    public static String replaceSpace(String s) {
        StringBuilder sb=new StringBuilder();
        int length=s.length();

        for(int i=0;i<length;i++){
            char c=s.charAt(i);
            if(c!=' '){
                sb.append(c);
            }else{
                sb.append("%20");
            }
        }

        return sb.toString();
    }
}
